package com.itqf.mybatis;

import com.itqf.mapper.BlogMapper;
import com.itqf.pojo.Blog;
import com.itqf.utils.SqlSessionUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * projectName: mybatisgp8
 *
 * @author: 赵伟风
 * time: 2021/7/30 15:06
 * description:多表对象查询
 */
public class ObjQuery {

    public static void main(String[] args) {


        SqlSession sqlSession = SqlSessionUtils.openSession();

        BlogMapper mapper = sqlSession.getMapper(BlogMapper.class);

        List<Blog> blogs = mapper.queryAll();

        for (Blog blog : blogs) {
            System.out.println("博客的信息:"+blog);
            System.out.println("博客的作者名:"+blog.getAuthor().getaName());
            System.out.println("--------------------------");
        }

        sqlSession.close();

    }

}
